/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cart;

import dto.Product;
import java.io.Serializable;

/**
 *
 * @author duonghung1369
 */
public class ShoppingCartItem implements Serializable {
    private int amount;
    private Product item;
    private double sub_total;

    public ShoppingCartItem() {
        amount = 1;
        sub_total = 0;
    }

    public ShoppingCartItem(int amount, Product item, float sub_total) {
        this.amount = amount;
        this.item = item;
        this.sub_total = sub_total;
    }

    /**
     * @return the amount
     */
    public int getAmount() {
        return amount;
    }

    /**
     * @param amount the amount to set
     */
    public void setAmount(int amount) {
        this.amount = amount;
    }

    /**
     * @return the item
     */
    public Product getItem() {
        return item;
    }

    /**
     * @param item the item to set
     */
    public void setItem(Product item) {
        this.item = item;
    }

    /**
     * @return the sub_total
     */
    public double getSub_total() {
        if(item != null){
            sub_total = item.getPrice() * amount;
        }
        return sub_total;
    }

    /**
     * @param sub_total the sub_total to set
     */
    public void setSub_total(double sub_total) {
        this.sub_total = sub_total;
    }

    
}
